#include <iostream>
#include <istream>
#include <deque>
#include <vector>
#include <map>

using namespace std;

template<typename T> class Lexer {

public:

 Lexer(basic_istream<T> *in, map<vector<T>, int> *tokenTable)
   : in(in), tokenTable(tokenTable) {
   readFromBuffer = false;
   currentTokenId = -1;
   compareIndex = 0;
 }
 
 virtual ~Lexer() {
   delete tokenQue;
 }
 
 void parse() {
 
   T nextChar = -1;
 
   basic_string<T> possibleIdentifier;
   map<vector<T>, int> *possibleTokenMatches = new map<vector<T>, int>(tokenTable);
   while((nextChar = readNextChar()) >= 0) {
    bool isCharWhitespace = isWhitespace(nextChar);
     if (isCharWhitespace && !possibleIdentifer.empty()) {
       currentToken = possibleIdentifer;
       currentTokenId = -1;
       return true;
     }
     possibleTokenMatches = getPossibleTokenMatches(possibleTokenMatches, nextChar, compareIndex);
     if (possibleTokenMatches.empty()) {
         if (isCharWhitespace 
     } else {
       if (isCharWhitespace && !possibleIdentifier.empty())
     }
   }
   return false;
 }
 
 map<vector<T>, int> *getPossibleTokenMatches(map<vector<T>, int> *compareTable, T compareChar, int compareIndex) {
   map<vector<T>, int> *possibleTokenMatches = new map<vector<T>, int>();
   
   return possibleTokenMatches;
 }

 
protected:
 bool readFromBuffer;
 deque<T> buffer;
 basic_istream<T> *in;
 vector<T> currentToken;
 int currentTokenId;
 deque<map<vector<T>, int> > *tokenQue;

 inline T readNextChar() {
     return readFromBuffer ? (buffer.empty() ? -1 : buffer.pop_front()) : (in->eof() ? -1 : in->get());
 }

 inline bool isWhitespace(T c) {
   return c == ' ' || c == '\t';
 }
 
private:
 int compareIndex;

};


int main(int argc, char**argv) {

 return 0;
}
